package com.angel.web.health;

import java.io.IOException;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;

import com.angel.core.util.FastDFSClient;
import com.angel.core.util.PropertyConfUtil;

/**
 * 高亚林
 * 2016年9月18日下午5:55:40
 */

@RequestMapping("/image")
@Controller
public class BuzImageController {

	@RequestMapping("/upload")
	public String upload(MultipartFile uploadFile){
		try {
			String imgBaseUrl = PropertyConfUtil.getContextProperty("imgBaseUrl");
			FastDFSClient client = new FastDFSClient();
			String originalFilename = uploadFile.getOriginalFilename();
			String extName = originalFilename.substring(originalFilename.lastIndexOf(".")+1);
			String path = client.uploadFile(uploadFile.getBytes(), extName);
			String uploadUrl = imgBaseUrl + path;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return "";
	}
}
